package cur.nature.component.quartz.controller;

import cur.nature.component.quartz.model.Component_QuartzLogVO;
import cur.nature.component.quartz.service.Component_QuartzLogService;
import cur.nature.framework.mvc.base.BaseAPI;
import cur.nature.framework.mvc.crud.CrudController;
import cur.nature.tinyorm.core.bean.PageBean;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 任务调度 Controller
 * 作者：Auto Generator By wujian
 * 生成日期：2024-04-28 18:27:31
 */
@Tag(name = "任务调度日志 接口")
@RestController
@RequestMapping("component/quartz/v1/api/Admin_QuartzLog")
@ConditionalOnProperty( value = {"cur.component.quartz.controller.enable"})
public class Component_QuartzLogController extends CrudController<Component_QuartzLogService> {
    public Component_QuartzLogController(Component_QuartzLogService baseService) {
        super(baseService);
    }

    @Operation(summary = "查询 任务调度")
    @PostMapping("/list")
    public PageBean<Component_QuartzLogVO> list(@Valid @RequestBody Component_QuartzLogVO.list_Param param) throws Exception {
        PageBean<Component_QuartzLogVO> list = getService().list(param);
        return list;
    }

    @Operation(summary = "更新 任务调度")
    @PostMapping("/operate")
    public BaseAPI.SaveResult<Component_QuartzLogVO> save(@Valid @RequestBody List<Component_QuartzLogVO> param) throws Exception {
        int rows = getService().saveList(param);
        BaseAPI.SaveResult result = new BaseAPI.SaveResult();
        result.setRows(rows);
        result.setObject(rows == 0 ? null : param);
        return result;
    }

}

